﻿function DoSearch() {
    $("#SearchInput").val($.trim($("#SearchInput").val()));
    var url = basePath + "NhanVien/DanhSachXeVanTai?SearchObject=" + $("#SearchObject").val()
        + "&SearchInput=" + $("#SearchInput").val();
    window.location.href = url;
}

function DoOpenNew() {
    DoClearMessage();
    window.location.href = basePath + "NhanVien/ThemMoiXeVanTai/-1";
}

function DoViewDetail(id) {
    DoClearMessage();
    window.location.href = basePath + "NhanVien/ThemMoiXeVanTai/" + id + "?Status=" + 1;
}

function DoClearMessage() {
    if (document.getElementById("Message") != null) {
        document.getElementById("Message").innerHTML = "&nbsp;";
    }
    if (document.getElementById("MessageError") != null) {
        document.getElementById("MessageError").innerHTML = "";
    }
    if (document.getElementById("MessageSearch") != null) {
        document.getElementById("MessageSearch").innerHTML = "";
    }
}



function DoDelete() {
    var lstId = "2";
    for (var z = 0; z < document.forms["form"].length; z++) {
        var item = document.forms["form"].elements[z];
        if (item.name == 'chk' && item.type == 'checkbox' && item.checked == true) {
            lstId = lstId + item.value + ",";
        }
    }
    if (IsEmpty(lstId)) {
        alert("Chọn một hồ sơ chưa duyệt để xóa ! ");
        return false;
    }
    if (confirm("Bạn có chắc muốn xóa những hồ sơ đã chọn ? ")) {
        DoOpenBox("boxWaitingForAjax");
        var url = basePath + "NhanVien/DeleteListXeVanTai/" + lstId;
        $.getJSON(url, null, function (data) {

        })
        .complete(function () {
            DoCloseBox("boxWaitingForAjax");
            //setTimeout(function () { $("#btnSearch").removeAttr("disabled"); }, 300);
        });
    }
}

function DoOpenBox(IdBox) {
    var hightwindown = $(document).height();
    var widthwindown = $(document).width();
    $("#" + IdBox).css({ "top": +(hightwindown / 2) + "px", "left": +(widthwindown / 2) + "px", "display": "block" });
    $("#boxBlockDisplay").css({ "width": +(widthwindown) + "px", "height": +(hightwindown) + "px", "display": "block" });
}

function DoCloseBox(IdBox) {
    $("#" + IdBox).css("display", "none");
    $("#boxBlockDisplay").css("display", "none");
}